package com.chao.converter;

import com.chao.dataObject.OrderMaster;
import com.chao.dto.OrderDTO;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * OrderMaster 转成 OrderDTO
 */
public class OrderMaster2OrderDTOConverter {

    public static OrderDTO convert(OrderMaster orderMaster) {

        OrderDTO orderDTO = new OrderDTO();

        BeanUtils.copyProperties(orderMaster, orderDTO);

        return orderDTO;
    }

    public static List<OrderDTO> converList(List<OrderMaster> orderMasterList) {

        // 可以用for循环去写

        return orderMasterList.stream().map(e -> convert(e)).collect(Collectors.toList());

    }
}
